<?php
if (!defined('ABSPATH')) {
	define('ABSPATH', dirname(dirname(__FILE__)) . '/');
}

require_once ABSPATH . 'dr-config.php';
require_once ABSPATH . DRINC . '/dr-base.php';
require_once ABSPATH . DRINC . '/dr-functions.php';


if (!isset($_SESSION)) {
	session_start();
}

$username = dr_post('username');
$email = dr_post('email');
$sys_captcha = $_SESSION['captcha'];
$user_captcha = dr_post('captcha');
$password = dr_post('password');

$status = -1;

if (!empty($username)) {
	if (dr_is_username_exist($username))
		$status = 0;
	elseif (!dr_is_username_valid($username))
		$status = 5;
	else
		$status = 10;
}

if (!empty($password)) {
	if (!dr_is_password_valid($password))
		$status = 4;
	else
		$status = 13;
}

if (!empty($email)) {
	if (dr_is_email_valid($email) == 1)
		$status = 1;
	else if (dr_is_email_valid($email) == 2)
		$status = 2;
	else
		$status = 11;
}

if (!empty($user_captcha)) {
	if (strtolower($user_captcha) == strtolower($sys_captcha))
		$status = 12;
	else
		$status = 3;
}

echo $status;

?>

